home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
timings.arc
/
REGCNV05.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-01-18
|
2KB
|
94 lines
title REGCNV05 -- Convert contents of AX to hex characters.
page 60,120
name REGCNV05 ; module
comment | Module Specifications
Copyright: None.
Environment: IBM PC, tested under DOS 2.0.
Segmentation: Program segment CODE, public, byte aligned, class ''.
Public symbols and external references: See Symbols section of listing.
Link requirements: None, standalone subroutine.
Program derived from: REGCNV04.
Original code by: Bob Smith and Tom Puckett, October 1983.
Modifications by: Bob Smith and Tom Puckett, October 1983.
Sequence of four ROL DX,1 replaced by single ROL DX,CL.
Procedure Specifications
Public Procedure REGCNV05 -- Convert value in AX to ASCII characters.
This is a subroutine to format and place in storage four ASCII
characters giving a hexadecimal representation of the value
passed in AX.
Assumptions: None.
Linkage: Near call and return.
Arguments: AX contains value to be formatted.
ES:DI point to destination where result is to be placed.
Effects: None.
Results: Flags and AX destroyed.
DI incremented by four.
Four hexadecimal digits formatted as ASCII characters
placed at ES:DI.
Return conditions: None.
Limitations: None.
|
page
code segment public byte
assume cs:code
hextable db '0123456789ABCDEF' ; for XLAT below
public REGCNV05
REGCNV05 proc near ; see specifications at head of listing
push bx ; preserve
push cx
push dx
cld ; for STOSB below
mov cl,4 ; for ROL below
mov dx,ax ; value to be formatted
mov ah,4 ; four hex digits to convert
mov bx,offset hextable ; translate table
digitloop:
rol dx,cl ; the fast way
mov al,dl
and al,0fh ; mask off what's not wanted
xlat hextable ; convert AL to ASCII
stosb ; stuff AL at ES:DI, update DI
dec ah ; loop counter
jnz digitloop
pop dx ; restore
pop cx
pop bx
ret
REGCNV05 endp
code ends ; end code segment
end ; end module